The present invention relates to cyclical redundancy checking and, in particular, to an apparatus and method for producing a variable width parallel cyclical redundancy check for use where link width may or may not correspond to CRC calculation width.
A cyclic redundancy check (xe2x80x9cCRCxe2x80x9d) is a method of detecting changes and error in blocks of data that have been transferred or stored. Generally, a CRC is a mathematical algorithm that acts on a block of data. The CRC divides the block of data by a particular number which is referred to as the xe2x80x9cCRC polynomialxe2x80x9d or the xe2x80x9cgenerator polynomialxe2x80x9d and leaves a remainder, referred to herein as the cyclic redundancy check value. Usually, this CRC value is transferred with the data, and when the data is received or recovered from storage, another division is performed and the remainder from the second division is compared to the remainder sent or stored with the data. If the received data has been changed, the remainders will not be the same. Upon detecting this difference, the receiver may request that the data be resent.
Many different CRC polynomials are in use, and the length of the polynomial determines the length of the CRC value. For example, a 16-bit polynomial will produce a 16 bit CRC value. In fact, the most important distinction between polynomials may be their length. Long polynomials ensure greater data accuracy, are usable over larger amounts of data, and are more likely to detect errors in the data transmission than short polynomials.
A CRC uses modulo two arithmetic to produce its CRC value This is a digital form of division that is fast and easy to implement. A polynomial division modulo two is similar to binary division and is implemented through the use of a register having the same length as the CRC value produced by the division. The register is used to compute the CRC value and store it, at least temporarily, after computation. The register is usually cleared before the division is performed and then initialized to all ones to prevents errors caused by extraneous zeros that may or may not be detected by the CRC check.
An apparatus for generating a cyclical redundancy check value for a variable number of input data bits is provided. The apparatus includes at least a first device for calculating a cyclical redundancy check value on a full set of bits of input data and producing a first value and a second device for calculating a cyclical redundancy check value on a first subset of the full set of bits of input data and producing a second value. A multiplexer, coupled to the first and second devices, receives the first and second values and a selection input to the multiplexer selects one of the values for further transmission. The apparatus also includes a register having an input coupled to the output of the multiplexer. A second multiplexer can be coupled between the first multiplexer and the register for selecting the selected value from the first multiplexer or the output from the register for input to the register. The output from the register may be fed back to the first and second devices through a logic gate which selects an initialization input for the initial input bits and thereafter selects the output value from the register. By adding a checker to the apparatus, it becomes suitable for checking a cyclical redundancy check value. The checker compares a cyclical redundancy value from within the input data with the output value from the register or in accordance with an alternative embodiment compares the output value from the register with a constant.
A method receives a variable number of input data bits and generates a cyclical redundancy check value. A cyclical redundancy check value is calculated for a total number of bits to produce a first calculated value. A cyclical redundancy check value is calculated for a first subset of the total bits to produce a second calculated value. One of the calculated values is selected and transmitted to a register. For checking a received cyclical redundancy check value, the data except for the received cyclical redundancy check value can be used to generate a cyclical redundancy check value for comparison with the received cyclical redundancy check value. Alternatively, a cyclical redundancy check value is calculated for the input bits including their received cyclical redundancy check value and the result is compared with a constant.